Repository navigation
R50-T009: Measure the work done by fibonacci (FibonacciNumberRecursive.js) [Recursive/FibonacciNumberRecursive.js] - #107
Open
stavansomaiya wants to merge 1 commit into
Conversation
…exing regression (R50-T009) Fixes: S-AI-Projects#9
This was referenced Nov 23, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
e26b07f1064Recursive/FibonacciNumberRecursive.js→fibonacci(line 9 at the pinned commit, line 19 after this PR)5c39e87·FibonacciNumberRecursive.js#L9stavansomaiya:student/e26b07f1064/R50-T009→S-AI-Projects:master(one commit on5c39e87)Summary
Adds a complexity statement to
Recursive/FibonacciNumberRecursive.js, backed by an experiment, plus a representative regression for the zero-based indexing the source uses.Complexity (input-size variable: the index n): the call count is exactly
C(n) = 2·F(n+1) − 1, fromC(0) = C(1) = 1andC(n) = 1 + C(n−1) + C(n−2). So time is Θ(φⁿ), and space is O(n) for the recursion stack. The function is deterministic, so this is both the worst case and every case. That is the proved claim; the experiment is a separate observation.Files changed
Recursive/FibonacciNumberRecursive.jsRecursive/test/FibonacciNumberRecursive.test.jswork/R50-T009/(9 files)check.pyrunner,README.mdwrite-up,evidence.mjs,results.jsonand logs; coursework only, kept out of any upstream PRRelated Issue
Fixes: #9
This PR covers only R50-T009. Each of the 10 tasks has its own branch, commit and PR; see All 10 tasks under Additional Notes.
Type of Change
Changes Made
Recursive/FibonacciNumberRecursive.js: JSDoc with the indexing convention and the complexity statement above. No logic change.Recursive/test/FibonacciNumberRecursive.test.js: indices 0, 1, 2, 5 and 10 → 0, 1, 1, 5 and 55.work/R50-T009/:check.py,evidence.mjsandtimings.json. For n = 20, 24 and 28 the measured call counts are 21,891, 150,049 and 1,028,457, exactly matching the formula (ratio 6.854 = φ⁴ each step). Timings use 5 repetitions per size and report the median and range.Screenshots / Recordings
There is no UI, so the recording is the terminal output of a fresh run on 23 Nov 2026. The run used a clean checkout of this branch with a new
npm cifrom the lockfile. The output is copied verbatim; only the temporary checkout path is replaced by a label.Focused tests:
npx vitest run … --reporter=verbose, 9/9 passedAutomated check:
python3 work/R50-T009/check.py, exit 0Testing
Automated check:
python3 work/R50-T009/check.pyinstalls from the lockfile and runs the focused tests. It then prints input / expected / actual for every fixture row, runs each deliberate mutant in a temporary copy, and finally runs the repository test script in non-watch mode. It exits non-zero if any assertion or step fails, and records every command incommands.log.To reproduce:
Recorded results (committed in
results.json; tool versions inversions.txt):npm ci --ignore-scripts --no-audit --no-fundvitest run Recursive/test/FibonacciNumberRecursive.test.jsnode work/R50-T009/evidence.mjscheck.pyfibonacci(2) is 1npm test(vitest run)npm run check-style(Prettier)codespellAcceptance criteria → evidence:
fibonacciin Recursive/FibonacciNumberRecursive.js; every assertion has an explicit expected value.fibonacci(0) is 0,fibonacci(1) is 1,fibonacci(2) is 1,fibonacci(5) is 5,fibonacci(10) is 55: each asserts a literal value.n < 2returnsn, lines 20-21).n. The call count is exactly2·F(n+1) − 1, so time is Θ(φⁿ) and space O(n). This is a proved bound that holds for every input, worst case included; the timings are labelled as an observation.Evidence files:
check.py·README.md(contract, fixture, baseline, findings) ·evidence.mjs·results.json·vitest-focused.jsonChecklist
Additional Notes
No pass/fail threshold depends on wall-clock speed; only values and exact call counts are asserted. Timing excludes process startup, module loading, I/O and JIT warm-up, and all outputs are checked against an independent iterative implementation outside the timed interval. Sensitivity check: widening the base case to
n <= 2in a temporary copy failsfibonacci(2) is 1.Scope: the PR changes only
Recursive/FibonacciNumberRecursive.js, its test file andwork/R50-T009/.work/R50-T009/is coursework evidence and would be removed from any later upstream PR.All 10 tasks (one PR each)
R50-T001R50-T002R50-T003R50-T004R50-T005R50-T006R50-T007R50-T008R50-T009R50-T010